<div class='admin-controls'>
  <div class='span15'>
    <ul class="nav nav-pills">
      <li>{{#linkTo 'adminUsersList.active'}}{{i18n admin.users.nav.active}}{{/linkTo}}</li>
      <li>{{#linkTo 'adminUsersList.new'}}{{i18n admin.users.nav.new}}{{/linkTo}}</li>
      {{#if Discourse.SiteSettings.must_approve_users}}
        <li>{{#linkTo 'adminUsersList.pending'}}{{i18n admin.users.nav.pending}}{{/linkTo}}</li>
      {{/if}}
      <li>{{#linkTo 'adminUsersList.admins'}}{{i18n admin.users.nav.admins}}{{/linkTo}}</li>
      <li>{{#linkTo 'adminUsersList.moderators'}}{{i18n admin.users.nav.moderators}}{{/linkTo}}</li>
      <li>{{#linkTo 'adminUsersList.banned'}}{{i18n admin.users.nav.banned}}{{/linkTo}}</li>
      <li>{{#linkTo 'adminUsersList.blocked'}}{{i18n admin.users.nav.blocked}}{{/linkTo}}</li>
    </ul>
  </div>
  <div class='span5 username controls'>
    {{textField value=username placeholderKey="username"}}
  </div>
</div>

{{#if hasSelection}}
  <div id='selected-controls'>
    <button {{action approveUsers}} class='btn'>{{countI18n admin.users.approved_selected countBinding="selectedCount"}}</button>
  </div>
{{/if}}

<h2>{{title}}</h2>
<br/>

{{#if loading}}
  <div class='admin-loading'>{{i18n loading}}</div>
{{else}}
  {{#if model.length}}
    <table class='table'>
      <tr>
        {{#if showApproval}}
          <th>{{view Ember.Checkbox checkedBinding="selectAll"}}</th>
        {{/if}}
        <th>&nbsp;</th>
        <th>{{i18n username}}</th>
        <th>{{i18n email}}</th>
        <th>{{i18n admin.users.last_emailed}}</th>
        <th>{{i18n last_seen}}</th>
        <th>{{i18n admin.user.topics_entered}}</th>
        <th>{{i18n admin.user.posts_read_count}}</th>
        <th>{{i18n admin.user.time_read}}</th>
        <th>{{i18n created}}</th>
        {{#if showApproval}}
          <th>{{i18n admin.users.approved}}</th>
        {{/if}}
        <th>&nbsp;</th>

      </tr>

      {{#each model}}
        <tr {{bindAttr class="selected"}}>
          {{#if controller.showApproval}}
            <td>
              {{#if can_approve}}
                {{view Ember.Checkbox checkedBinding="selected"}}
              {{/if}}
            </td>
          {{/if}}
          <td>{{#linkTo 'adminUser' this}}{{avatar this imageSize="small"}}{{/linkTo}}</td>
          <td>{{#linkTo 'adminUser' this}}{{unbound username}}{{/linkTo}}</td>
          <td>{{shorten email}}</td>
          <td>{{{unbound last_emailed_age}}}</td>
          <td>{{{unbound last_seen_age}}}</td>
          <td>{{{unbound topics_entered}}}</td>
          <td>{{{unbound posts_read_count}}}</td>
          <td>{{{unbound time_read}}}</td>

          <td>{{{unbound created_at_age}}}</td>

          {{#if showApproval}}
          <td>
            {{#if approved}}
              {{i18n yes_value}}
            {{else}}
              {{i18n no_value}}
            {{/if}}
          </td>
          {{/if}}
          <td>
            {{#if admin}}<i class="icon-trophy" title="{{i18n admin.title}}"></i>{{/if}}
            {{#if moderator}}<i class="icon-magic" title="{{i18n admin.moderator}}"></i>{{/if}}
          <td>
        </tr>
      {{/each}}

    </table>
  {{else}}
    <p>{{i18n search.no_results}}</p>
  {{/if}}
{{/if}}
